package com.feicheng.lanniao.controller;


import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.IHouseBuyInfoService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-07
 */
@RestController
@RequestMapping("/lanniao-admin/house-buy-info")
public class HouseBuyInfoController {

	@Autowired
	private IHouseBuyInfoService iHouseBuyInfoService;

	/**
	 * 新增买房
	 * @param title 标题
	 * @param detail 详情
	 * @param clientId 客户id
	 * @param tel 发布人电话
	 * @param wxNumber 发布人微信
	 * @return 布尔值 true-成功 false-失败
	 */
	@PostMapping("/info")
	public ResultInfo add(String tel, 
			String wxNumber,
			String title,
			String detail,
			Integer clientId) {
		
		return iHouseBuyInfoService.add(tel,
				wxNumber,
				title, 
				detail, 
				clientId);
	}
	
	/**
	 * 查看买房详情
	 * @param houseBuyId 买房id
	 * @return 返回买房详情
	 */
	@GetMapping("/info")
	public ResultInfo inFo(Integer houseBuyId) {
		return ResultInfo.success(iHouseBuyInfoService.getById(houseBuyId));
	}

	/**
	 * 删除买卖房信息
	 * @param houseBuyId 买房id
	 * @return 布尔值 true-成功 false-失败
	 */
	@DeleteMapping("/info")
	public ResultInfo remove (Integer houseBuyId) {
		return ResultInfo.success(iHouseBuyInfoService.remove(houseBuyId));
	}

	/**
	 * 修改一个买房信息
	 * @param houseBuyId 买房id
	 * @param title 标题
	 * @param detail 详情
	 * @param clientId 客户id
	 * @return 布尔值 true-成功 false-失败
	 */
	@PutMapping("/info")
	public ResultInfo edit (Integer houseBuyId,String title,String detail,String tel,String wxNumber, Integer clientId) {
		return ResultInfo.success(iHouseBuyInfoService.edit(houseBuyId, title, detail, tel, wxNumber, clientId));
	}
}

